package com.zxjlib.core.base;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageInfo;
import com.zxjlib.core.base.response.BaseAbstractResult;

public class CommonResult extends BaseAbstractResult {

    private Long                total = 0L;

    private Map<String, Object> data  = new HashMap<String, Object>();

    private List<?>             rows  = Collections.emptyList();

    public CommonResult() {
        super();
    }

    public CommonResult(List<?> list) {
        setRows(list);
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public List<?> getRows() {
        return rows;
    }

    public void setRows(List<?> rows) {
        this.rows = rows;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public void putData(String key, Object value) {
        data.put(key, value);
    }

    public Object getData(String key) {
        return data.get(key);
    }

    public void setPageInfo(PageInfo page) {
        setTotal(page.getTotal());
        setRows((List) page);
    }

    public void setEasyuiDataGrid(PageInfo pageInfo) {
        setTotal(pageInfo.getTotal());
        setRows(pageInfo.getList());
    }
}
